// ========================================================================= //

// includes
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "string.h"
#include "limits.h"
#include "float.h"



#define JOTAI_NUM_RANDS_ 25

const unsigned rand_primes[JOTAI_NUM_RANDS_] = {179, 103, 479, 647, 229, 37, 271, 557, 263, 607, 18743, 50359, 21929, 48757, 98179, 12907, 52937, 64579, 49957, 52567, 507163, 149939, 412157, 680861, 757751};

int next_i() {
  int counter = 0;
  return rand_primes[(++counter)%JOTAI_NUM_RANDS_];
}

float next_f() {
  int counter = 0;
  return rand_primes[(++counter)%JOTAI_NUM_RANDS_] / 757751.0F;
} 


// Usage menu
void usage() {
    printf("%s", "Usage:\n\
    prog [ARGS]\n\
\nARGS:\n\
       0            empty\n\
\n\
");

}


// ------------------------------------------------------------------------- //

#define NULL ((void*)0)
typedef unsigned long size_t;  // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__;  // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct iwl_nvm_data {struct ieee80211_channel* channels; } ;
struct iwl_eeprom_enhanced_txpwr {int flags; scalar_t__ channel; } ;
struct ieee80211_channel {scalar_t__ hw_value; int band; scalar_t__ max_power; } ;
typedef  scalar_t__ s8 ;
typedef  enum nl80211_band { ____Placeholder_nl80211_band } nl80211_band ;

/* Variables and functions */
 int IWL_EEPROM_ENH_TXP_FL_40MHZ ; 
 int IWL_EEPROM_ENH_TXP_FL_BAND_52G ; 
 int NL80211_BAND_2GHZ ; 
 int NL80211_BAND_5GHZ ; 

__attribute__((used)) static void
iwl_eeprom_enh_txp_read_element(struct iwl_nvm_data *data,
				struct iwl_eeprom_enhanced_txpwr *txp,
				int n_channels, s8 max_txpower_avg)
{
	int ch_idx;
	enum nl80211_band band;

	band = txp->flags & IWL_EEPROM_ENH_TXP_FL_BAND_52G ?
		NL80211_BAND_5GHZ : NL80211_BAND_2GHZ;

	for (ch_idx = 0; ch_idx < n_channels; ch_idx++) {
		struct ieee80211_channel *chan = &data->channels[ch_idx];

		/* update matching channel or from common data only */
		if (txp->channel != 0 && chan->hw_value != txp->channel)
			continue;

		/* update matching band only */
		if (band != chan->band)
			continue;

		if (chan->max_power < max_txpower_avg &&
		    !(txp->flags & IWL_EEPROM_ENH_TXP_FL_40MHZ))
			chan->max_power = max_txpower_avg;
	}
}

// ------------------------------------------------------------------------- //

int main(int argc, char *argv[]) {

    if (argc != 2) {
        usage();
        return 1;
    }

    int opt = atoi(argv[1]);
    switch(opt) {


    // empty
    case 0:
    {
          // static_instructions_O0 : 21
          // dynamic_instructions_O0 : 21
          // ------------------------------- 
          // static_instructions_O1 : 11
          // dynamic_instructions_O1 : 11
          // ------------------------------- 
          // static_instructions_O2 : 11
          // dynamic_instructions_O2 : 11
          // ------------------------------- 
          // static_instructions_O3 : 11
          // dynamic_instructions_O3 : 11
          // ------------------------------- 
          // static_instructions_Ofast : 11
          // dynamic_instructions_Ofast : 11
          // ------------------------------- 
          // static_instructions_Os : 11
          // dynamic_instructions_Os : 11
          // ------------------------------- 
          // static_instructions_Oz : 17
          // dynamic_instructions_Oz : 17
          // ------------------------------- 

          int n_channels = ((-2 * (next_i()%2)) + 1) * next_i();
        
          long max_txpower_avg = ((-2 * (next_i()%2)) + 1) * next_i();
        
          int _len_data0 = 1;
          struct iwl_nvm_data * data = (struct iwl_nvm_data *) malloc(_len_data0*sizeof(struct iwl_nvm_data));
          for(int _i0 = 0; _i0 < _len_data0; _i0++) {
              int _len_data__i0__channels0 = 1;
          data[_i0].channels = (struct ieee80211_channel *) malloc(_len_data__i0__channels0*sizeof(struct ieee80211_channel));
          for(int _j0 = 0; _j0 < _len_data__i0__channels0; _j0++) {
              data[_i0].channels->hw_value = ((-2 * (next_i()%2)) + 1) * next_i();
          data[_i0].channels->band = ((-2 * (next_i()%2)) + 1) * next_i();
          data[_i0].channels->max_power = ((-2 * (next_i()%2)) + 1) * next_i();
        
          }
        
          }
        
          int _len_txp0 = 1;
          struct iwl_eeprom_enhanced_txpwr * txp = (struct iwl_eeprom_enhanced_txpwr *) malloc(_len_txp0*sizeof(struct iwl_eeprom_enhanced_txpwr));
          for(int _i0 = 0; _i0 < _len_txp0; _i0++) {
              txp[_i0].flags = ((-2 * (next_i()%2)) + 1) * next_i();
          txp[_i0].channel = ((-2 * (next_i()%2)) + 1) * next_i();
        
          }
        
          iwl_eeprom_enh_txp_read_element(data,txp,n_channels,max_txpower_avg);
          for(int _aux = 0; _aux < _len_data0; _aux++) {
          free(data[_aux].channels);
          }
          free(data);
          free(txp);
        
        break;
    }

    default:
        usage();
        break;

    }

    return 0;
}
